//
//  YWaterFlowView.h
//  yuimall_Iphone
//
//  Created by yuike6 yuike6 on 12-4-6.
//  Copyright (c) 2012年 yuike. All rights reserved.
//

#import "YWaterFlowCell.h"

@protocol WaterflowViewDatasource;
@protocol WaterflowViewDelegate;
@interface YWaterFlowView : UIScrollView<UIScrollViewDelegate>
{
    NSInteger numberOfColumns ; 
    NSInteger currentPage;
	
	NSMutableArray *_cellHeight; 
	NSMutableArray *_visibleCells; 
	NSMutableDictionary *_reusedCells; 
	
	id <WaterflowViewDelegate> _flowdelegate;
    id <WaterflowViewDatasource> _flowdatasource;
}
- (void)reloadData;

- (id)dequeueReusableCellWithIdentifier:(NSString *)identifier;

@property (nonatomic, retain) NSMutableArray *cellHeight; //array of cells height arrays, count = numberofcolumns, and elements in each single child array represents is a total height from this cell to the top
@property (nonatomic, retain) NSMutableArray *visibleCells;  //array of visible cell arrays, count = numberofcolumns
@property (nonatomic, retain) NSMutableDictionary *reusableCells;  //key- identifier, value- array of cells
@property (nonatomic, assign) id <WaterflowViewDelegate> flowdelegate;
@property (nonatomic, assign) id <WaterflowViewDatasource> flowdatasource;


@end





@protocol WaterflowViewDatasource <NSObject>
@required
- (NSInteger)numberOfColumnsInFlowView:(YWaterFlowView*)flowView;
- (NSInteger)flowView:(YWaterFlowView *)flowView numberOfRowsInColumn:(NSInteger)column;
- (YWaterFlowCell *)flowView:(YWaterFlowView *)flowView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
@end


@protocol WaterflowViewDelegate <NSObject>
@required
- (CGFloat)flowView:(YWaterFlowView *)flowView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
@optional
- (void)flowView:(YWaterFlowView *)flowView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;
@end
